package com.foreknow.elmboot.mapper;

import com.foreknow.elmboot.po.DeliveryAddress;
import org.apache.ibatis.annotations.*;

import java.sql.SQLException;
import java.util.List;

@Mapper
public interface DeliveryAddressMapper {
    //根据用户编号查询所属送货地址
    @Select("select * from deliveryaddress where userId = #{userId}")
    public List<DeliveryAddress> queryById(String userId);
    //根据送货地址编号查询送货地址
    @Select("select * from deliveryaddress where daId = #{daId}")
    public DeliveryAddress queryDABbId(Integer daId);
    //向送货地址表中添加一条记录
    @Insert("insert into deliveryaddress (contactName,contactSex,contactTel,address,userId) values (#{contactName},#{contactSex},#{contactTel},#{address},#{userId})")
    public int insert(String contactName,Integer contactSex,String contactTel,String address,String userId);
    //根据送货地址编号更新送货地址信息
    @Update("update deliveryaddress set contactName=#{contactName},contactSex=#{contactSex},contactTel=#{contactTel},address=#{address},userId=#{userId} where daId = #{daId}")
    public int update(DeliveryAddress deliveryAddress);
    //根据送货地址编号删除一条记录
    @Delete("delete from deliveryaddress where daId = #{daId}")
    public int delete(Integer daId);
}
